﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EWDTAssignment.App_Code;

namespace EWDTAssignment
{
    public partial class Compare : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //FOR TESTING! REMEMBER TO DELETE!
            Session["AccountID"] = 1;

            if (Session["AccountID"] != null)
            {
                if (!IsPostBack)
                {
                    int accID = Convert.ToInt32(Session["AccountID"]);
                    BusinessLogic.populateSetList(ddlSet1, accID);
                    BusinessLogic.populateSetList(ddlSet2, accID);
                }
            }
            else
            {
                Response.Redirect("Login.aspx");
            }
        }

        protected void ddlSet1_SelectedIndexChanged(object sender, EventArgs e)
        {
            BusinessLogic.GenerateSetList(Convert.ToInt32(ddlSet1.SelectedValue), BusinessLogic.CreateLabelList(SetID1,MB1,CPU1,RAM1,GFX1,HDD1,Sound1,PSU1,Casing1));
        }

        protected void ddlSet2_SelectedIndexChanged(object sender, EventArgs e)
        {
            BusinessLogic.GenerateSetList(Convert.ToInt32(ddlSet2.SelectedValue), BusinessLogic.CreateLabelList(SetID2, MB2, CPU2, RAM2, GFX2, HDD2, Sound2, PSU2, Casing2));
        }

        protected void btnCompare_Click(object sender, EventArgs e)
        {
            if (ddlSet1.SelectedIndex > 0 && ddlSet2.SelectedIndex > 0)
            {
                List<int> setID = new List<int>();
                setID.Add(Convert.ToInt32(ddlSet1.SelectedValue));
                setID.Add(Convert.ToInt32(ddlSet2.SelectedValue));
                BusinessLogic.CompareSets(BusinessLogic.CreateLabelList(SetID1, MB1, CPU1, RAM1, GFX1, HDD1, Sound1, PSU1, Casing1), BusinessLogic.CreateLabelList(SetID2, MB2, CPU2, RAM2, GFX2, HDD2, Sound2, PSU2, Casing2), setID);
            }
        }

        
    }
}